import 'package:flutter/material.dart';
import 'package:flutter_app/config/colorconfig.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

class spotPage extends StatefulWidget {
  final nowspot;
  spotPage(this.nowspot);
  @override
  _spotPageState createState() => _spotPageState(this.nowspot);
}
//传入nowSpot：
//  id<num> title<string> image<list> intro<string> other<string> remark<list>D
class _spotPageState extends State<spotPage> {
  final _nowSpot;
  _spotPageState(this._nowSpot);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text(
          _nowSpot.title,
          style: TextStyle(color: darkgreen),
        ),
      ),
      body: ListView.builder(
        itemCount: 4,
        itemBuilder: (BuildContext context, int index) {
          if (index == 0) return Divider(thickness: 15, color: defaultgreen);
          if (index == 1)//图片
            return Container(
              height: MediaQuery.of(context).size.width * 0.44,
              child: Swiper(
                itemCount: _nowSpot.image.length,
                itemBuilder: (BuildContext context, int imageindex) {
                  return _nowSpot.image[imageindex];
                },
              ),
            );
          if (index == 2) {//详情
            return Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                Text(_nowSpot.name),
                Text(_nowSpot.intro,
                    textScaleFactor: 0.7,
                    style: TextStyle(color: defaultgreen)),
                Text(_nowSpot.other,
                    textScaleFactor: 0.7,
                    style: TextStyle(color: defaultgreen)),
              ],
            );
          }
          if (index == 3) {
            return Divider(thickness: 5, color: defaultgreen);
          }
          if (index == 4) {//评论按钮
            return Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: <Widget>[
                FlatButton(
                  onPressed: () {},
                  textColor: darkgreen,
                  shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.all(Radius.circular(20))),
                  child: Text(
                    '说点什么······',
                  ),
                  color: defaultgreen,
                ),
              ],
            );
          }
          return ListTile(//评论

          );
        },
      ),
    );
  }
}
